class verify{
    constructor(textid,verifyingfun){
        this.input=document.querySelector('#'+textid);
        this.p=this.input.nextElementSibling;//找到下一个兄弟元素
        this.verifyingfun=verifyingfun;
        this.input.onblur=()=>{
            this.vaildata();
        }
    }
   async vaildata(){
       const err=await this.verifyingfun(this.input.value);
       if(!err){
        return true;
       }else{
        this.p.innerHTML=err;
        return false;
       }
    }
    static async vaildatatotal(...data){
        const pro=data.map(item=>item.vaildata());//返回的是promise
        const result=await Promise.all(pro);//等待所有执行完毕，返回的是数组，如：[true,false]
        return result.every(item=>item);//判断所有项是否都满足条件 
    }
}
